function avg() {
    var sum = 0;
    for (i = 0; i < arguments.length; i++) {
        sum += arguments[i];
    }
    return sum / arguments.length;
}
function avg2(...para) {
    var sum = 0;
    for (i = 0; i < para.length; i++) {
        sum += para[i];
    }
    return sum / para.length;
}
function max(arr) {
    var max = 0;
    for (i = 0; i < arr.length; i++) {
        if (arr[i] > max) {
            max = arr[i]
        }
    }
    return max;
}
function max2(arr) {
    return Math.max(...arr);
}

function area_of_circle(r, p) {
    pi = p || 3.14;
    return Math.pow(r, 2) * pi;
}
function area_of_circle2(r, pi=3.14) {
    return Math.pow(r, 2) * pi;
}
console.log(avg(1, 2, 3, 4, 5));
console.log(avg2(1, 2, 3, 4, 5));
console.log(max([10, 9, 15, 12, 7]));
console.log(max2([10, 9, 15, 12, 7]));
if (area_of_circle(2) === 12.56 && area_of_circle(2, 3.1416) === 12.5664) {
    console.log('测试通过');
} else {
    console.log('测试失败');
}
if (area_of_circle2(2) === 12.56 && area_of_circle2(2, 3.1416) === 12.5664) {
    console.log('测试通过');
} else {
    console.log('测试失败');
}